package top.skihub.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;
import top.skihub.pojo.MineInfo;

import java.util.List;

@Service
@Mapper
public interface MineInfoMapper {
    @Insert("insert into mine_info (user_id, user_name, motto, phone, email, address, birthday, passwd) " +
            "values(#{userId}, #{userName}, #{motto}, #{phone}, #{email}, #{address}, #{birthday}, #{passwd})")
    void insert(MineInfo mineInfo);

    @Select("select user_id, user_name, motto, phone, email, address, birthday, passwd " +
            "from mine_info where email = #{email}")
    List<MineInfo> list(String email);

    @Select("select user_id, user_name, motto, phone, email, address, birthday, passwd " +
            "from mine_info where phone = #{phone} and passwd = #{passwd}")
    List<MineInfo> getMineInfo(String phone, String passwd);

    @Update("update mine_info set user_name = #{userName}, motto = #{motto}, " +
            "phone = #{phone}, address = #{address}, birthday = #{birthday} " +
            "where email = #{email}")
    void updateMineInfo(MineInfo mineInfo);
}
